package com.tom.config;

import com.alibaba.fastjson.JSON;
import com.tom.domain.Login;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * 获取登录的login
 */
public class GetLogin {
    public static Login getLogin(){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        String s = authentication.getPrincipal().toString();
        // 将json类型转化为login对象
        Login login = JSON.parseObject(s, Login.class);
        return login;
    }
}
